<%@ include file="../init.jsp" %>

<%@ page import="java.util.List" %>
<%@ page import="uit.edu.vn.portal.elearning.models.schedule.*" %>
<%@ page import="uit.edu.vn.portal.elearning.logic.SakaiWSLogic" %>
<%@ page import="uit.edu.vn.portal.elearning.helper.SakaiWSHelper" %>
<%@ page import="java.util.Date" %>

<%
	List<CalendarEvent> schedules = (List<CalendarEvent>)request.getAttribute("schedules");
	String sakaiurl = application.getInitParameter("sakai.server.url");
	SakaiWSLogic logic = (SakaiWSLogic)request.getAttribute("logic");
%>
<table>
<tr>
	<th><liferay-ui:message key="schedule-title" /></th>
	<th><liferay-ui:message key="schedule-location" /></th>
	<th><liferay-ui:message key="schedule-type" /></th>
	<th><liferay-ui:message key="schedule-frequency" /></th>
	<th><liferay-ui:message key="schedule-course" /></th>
</tr>
<% 
	for(CalendarEvent event:schedules ){ 
		String linktosakai = sakaiurl + event.getPageUrl();
		String site_title = SakaiWSHelper.getSiteTitle(logic,event.getSiteid());
		RecurrenceRule rule = event.getRecurrenceRule();
		String frequencyDescription = "";
		if(rule != null)
			frequencyDescription =  rule.getFrequencyDescription();
		
		String location = (event.getLocation() != null)?event.getLocation():"";
			
%>
<tr>
	<td width="20%"><a href="<%= linktosakai %>"><%= event.getDisplayName()%></a></td>
	<td width="20%"><%= location %></td>
	<td width="25%"><%= event.getType()%></td>
	<td width="15%"><%= frequencyDescription %></td>
	<td width="20%"><a href="<%= linktosakai %>"><%= site_title %></a></td>
</tr>
<% } %>
</table>


